<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="${package}.mapper.${entityName}Mapper">

    <sql id="Base_Column_List">
        <#list table.columns as column>
        t.${column.name}<#if column_has_next>,</#if>
        </#list>
    </sql>

    <select id="selectPage" resultType="${package}.entity.${entityName}">
        SELECT <include refid="Base_Column_List"/>
        FROM ${table.name} t
        <where>
        <#list table.columns as column>
            <#assign camelName = CodeGeneratorUtils.toCamelCase(column.name, false)>
            <#if column.type == "varchar">
                <if test="query.${camelName} != null and query.${camelName} != ''">
                    AND t.${column.name} = <#noparse>#</#noparse>{query.${camelName}}
                </if>
            <#else>
                <if test="query.${camelName} != null">
                    AND t.${column.name} = <#noparse>#</#noparse>{query.${camelName}}
                </if>
            </#if>
        </#list>
        </where>
    </select>
</mapper>